/*
 * @Author: yangy
 * @Date: 2023-11-06 11:25:32
 * @LastEditors: yangy
 * @LastEditTime: 2023-11-28 11:10:27
 * @FilePath: /qn_mall_frontend/src/store/cart.js
 * @Description:
 *
 * Copyright (c) 2023 by 青柠利合科技(北京)有限公司, All Rights Reserved.
 */
// 购物车相关状态

import { defineStore } from 'pinia'

export const useCartStore = defineStore('cart', {
  // state: () => {
  //   return {
  //     goodsCartNum: 0
  //   }
  // },
  state: () => ({
    goodsCartNum: 0
  }),
  actions: {
    setGoodsNum(num) {
      this.goodsCartNum = num
    },
    getGoodsNum() {
      return this.goodsCartNum
    },
    //  获取购物车中商品的数量    // async getGoodsNum(params) {
    //   // axios 请求
    //   return 2
    // },
    update({ commit }) {
      // 假设请求
      setTimeout(() => {
        commit('update')
      }, 2000)
    }
  }
})
